package jdk;

import java.lang.reflect.Proxy;

/**
 * @ClassName jdkPorxy
 * @Description
 * @Author lichuanqi
 * @Date 2022/5/2 15:14
 * @Version 1.0
 **/
public class JdkProxyTest {
    public static void main(String[] args) {
        TargetClass targetClass = new TargetClass();
        MyInvocationHandler myInvocationHandler = new MyInvocationHandler(targetClass);
        CommonInterface proxy = (CommonInterface) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
                targetClass.getClass().getInterfaces(),
                myInvocationHandler);
        proxy.sayHello();
    }
}
